class Number
Description
Extensions to the built-in Number
object.
Instance methods
-
constrain #
Number#constrain(min, max) -> Number
Returns
min
if number is less thanmin
,max
if number is greater thanmax
. Returns itself otherwise. -
nearer #
Number#nearer(n1, n2) -> Number
Returns either
n1
orn2
— whichever is closer to the number, in absolute terms. -
tween #
Number#tween(target, position) -> Number
-
target
(Number
) – tween target -
position
(Number
) – position between 0 (start of tween) and (end of tween); can also be < 0 and > 1.
Returns the number that is a given percentage between this number and a target number.
(1).tween(2, 0.5) -> 1.5 (1).tween(2, 0) -> 1 (1).tween(2, 1) -> 2
-